# -*- coding: utf-8 -*-
# 文件工具类

file_dict = {}


def file_read():
    with open('user.txt') as f:
        for line in f.read().split('\n'):
            if line:
                tmp = line.split(':')
                file_dict[tmp[0]] = tmp[1]

        return file_dict


def file_write():
    file_arr = []
    for user, pwd in file_dict.items():
        file_arr.append('{}:{}'.format(user, pwd))

    with open(r'user.txt', 'w', encoding='UTF-8') as f:
        f.write('\n'.join(file_arr))
        f.flush()
